/**
 * @desc 随机生成字符串
 * @param length
 * @returns {string}
 */
export const generateRandomString = (length) => {
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    let result = '';
    const charactersLength = characters.length;
    for (let i = 0; i < length; i++) {
        result += characters.charAt(Math.floor(crypto.getRandomValues(new Uint32Array(1))[0] % charactersLength));
    }
    return result;
}

/**
 * @desc 随机生成颜色
 * @returns {string}
 */
export const generateRandomColor = () => {
    // 生成一个0-255之间的随机整数
    function getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    // 使用RGB颜色空间生成颜色
    return `rgb(${getRandomInt(0, 255)}, ${getRandomInt(0, 255)}, ${getRandomInt(0, 255)})`;
}